1. Field of the Invention
The present invention relates to an image coding apparatus and an image coding method that perform inter-prediction between pictures to compress and code input images.
2. Description of the Related Art
As technologies for coding images with high efficiency, coding methods, such as the Joint Photographic Experts Group (JPEG) method and the Moving Picture Experts Group (MPEG) 1 and 2 methods using motion prediction and motion compensation, have been established. Manufacturers have been developing and manufacturing image-capturing apparatuses, such as digital cameras and video cameras, and digital versatile disc (DVD) recorders that are capable of recording images using such coding methods. In addition to these apparatuses, users have been able to easily view recorded images using personal computers or DVD players.
The amount of data contained in digitized moving images is huge. Thus, moving image coding methods capable of achieving higher compression compared with the above-mentioned MPEG 1 or 2 have been studied. In recent years, a coding method called H.264/MPEG-4 part 10 (advanced video coding (AVC)) (hereinafter, referred to as an “H.264 coding method”) has been standardized by the International Telecommunication Union-Telecommunication Standardization Sector (ITU-T) and the International Standardization Organization (ISO).
Selection of picture types and reference images used for inter-picture prediction in the H.264 coding method will be described with reference to FIGS. 21A to 21C and FIGS. 22A to 22B. FIGS. 21A to 21C and FIGS. 22A to 22B show input image streams and picture types.
Referring to FIGS. 21A to 21C and FIGS. 22A to 22B, the upper part of each figure represents a display order in which pictures are displayed from the left to right, and the lower part of each figure represents a coding order in which pictures are coded from the left to right. For example, a picture P8 in FIG. 21A represents the frame of a P picture that is displayed ninth. In addition, arrows in FIGS. 21A to 21C and FIGS. 22A to 22B represent a reference relationship. For example, in the example shown in FIG. 21A, the picture P8 refers to a picture B0. In the example shown in FIG. 21B, the picture B0 refers to a picture P2 and a picture B7.
As picture types of image frames in the H.264 coding method, I pictures that are coded using information within the same frame, P pictures that are coded using a difference from the temporally preceding frame, and B pictures that are coded using a difference from the temporally preceding frame or the temporally succeeding frame are provided.
In addition, in the H.264 coding method, any picture and any picture type within an image stream can be used as a reference image when inter-picture prediction is performed. For example, as shown in FIG. 21A, the picture P8 (P picture) is capable of referring to a picture beyond a picture I5, which is the I picture immediately before the picture P8. Similarly, as shown in FIG. 21B, the picture B0 (B picture) is capable of referring to a picture beyond the picture I5, which is the I picture immediately after the picture B0. As described above, the H.264 coding method permits flexible reference. Thus, compared with a case of the MPEG 2 method in which a P picture is only capable of referring to the I or P picture immediately before the P picture, the accuracy of inter-picture prediction and coding efficiency can be improved.
However, due to such flexible reference being allowed, rapid random access may not be achieved. As an example, a case shown in FIG. 21C in which playback is started from the picture I5 (I picture), which is in the middle of an image stream, by random access will be explained.
When playback is started from the picture I5 in the middle of the image stream and the picture P8 (P picture) is decoded, since the picture P8 refers to the picture B0 (B picture), it is necessary to decode the picture B0 in advance. In addition, since the picture B0 refers to the picture P2 (P picture) and the picture B7 (B picture), it is necessary to decode the pictures P2 and B7 in advance. Similarly, although not illustrated, since the pictures P2 and B7 refer to other pictures, it is also necessary to decode the corresponding pictures in advance. As described above, even in a case where playback is started from the picture I5, which is an I picture, since reference beyond the I picture can be permitted, it is necessary to start decoding from data before the picture I5. Thus, it is difficult to quickly start decoding from the picture I5.
Thus, in order to solve the above-mentioned problem and to achieve rapid random access, a method for regularly imposing a restriction on a motion reference relationship of an I picture is suggested, for example, in Japanese Patent Laid-Open No. 2003-199112. In the H.264 coding method, such a conditional I picture is referred to as an instantaneous decoder refresh (IDR) picture.
IDR pictures will be described with reference to FIGS. 22A and 22B. Image streams shown in FIGS. 22A and 22B are different from the image streams shown in FIGS. 21A and 21B in that the picture I5 is set as an IDR picture. When the picture I5 (I picture) is set as a picture IDR5 (IDR picture), a frame memory in which a reference image is recorded is cleared when the IDR picture is coded. Thus, a picture to be coded after the picture IDR5 cannot refer to a picture that is coded before the picture IDR5. Similarly, a picture coded before the picture IDR5 cannot refer to a picture to be coded after the picture IDR5.
In the example shown in FIG. 22A, P pictures and B pictures to be coded after the picture IDR5 (that is, the pictures P8, B6, and the like) cannot refer to P pictures and B pictures coded before the picture IDR5 (that is, the pictures P2, B0, and the like). Similarly, in the example shown in FIG. 22B, P pictures and B pictures coded before the picture IDR5 (that is, the pictures P2, B0, and the like) cannot refer to P pictures and B pictures to be coded after the picture IDR5 (that is, the pictures P8, B6, and the like).
That is, since the reference relationship is reset by an IDR picture, when playback is started from the IDR picture, it is not necessary to decode a picture before the IDR picture. Thus, random access can be easily performed.
As described above, in the H.264 coding method, random access can be performed easily by utilizing an IDR picture that restricts the reference relationship in inter-picture prediction. Thus, in order to achieve random access to a desired position of an image stream, it is necessary to set many IDR pictures. However, since the amount of generated code for an IDR picture to be coded using information within the picture is large, setting a large number of pictures as IDR pictures may deteriorate coding efficiency. In addition, if many IDR pictures are used, the originally provided flexible reference relationship in the H.264 coding method may be restricted. Thus, the efficiency of inter-picture coding may also be deteriorated.
Thus, it is desirable to set a minimum number of IDR pictures. When an IDR picture is regularly set, as in the known technology, even a picture that is not necessary for random access is set as an IDR picture. Thus, coding efficiency is deteriorated.